USB port shared control method in a plurality of virtual machines

ABSTRACT

A USB port shared control method executed by a hypervisor controlling port sharing among virtual machines and having a physical USB host controller including a physical register, the virtual machines each including a virtual USB host controller having a virtual register. The method includes performing sharing by: selectively allocating the physical register to the virtual register of a subject virtual USB host controller provided in a subject virtual machine of the plurality of virtual machines to occupy and unitize the USB port by the subject virtual machine, and directly reading or writing of the physical register by the subject virtual machine via the subject virtual USB host controller, to thereby allow the subject virtual USB host controller to directly control the physical USB host controller. More particularly, the allocating, reading and writing are switched from subject virtual machine to subject virtual machines to facilitate sharing.

INCORPORATION BY REFERENCE

The present application claims priority from Japanese applicationJP2008-027761 filed on Feb. 7, 2008, the content of which is herebyincorporated by reference into this application.

BACKGROUND OF THE INVENTION

The present invention is related to a USB (Universal Serial Bus) portshared control method and pertains, in particular, to a USB port sharedcontrol method making it possible to let a plurality of virtual machinesjointly utilize a physical USB host controller with which a USB deviceis connected via a physical USB port installed in a physical machine,and to let a single virtual machine occupy and utilize a physical USBport.

Normally, in case a USB device is connected with a USB port, theconnection state is reflected in the PORTSC register which displays orcontrols the state of the port in the register of the physical USB hostcontroller. And then, the USB drive of the computer, observing thecontents of this PORTSC register, starts control of the physical port.

Moreover, in order to let a virtual machine use the physical USB hostcontroller installed in the physical machine, virtualization of the USBhost controller in the virtual machine is necessary. The virtualizationof a USB host controller in a virtual machine such as this isimplemented by carrying out, by means of shared technology based ondevice virtualization, device emulation with respect to the physical USBhost controller by means of a hypervisor configured inside the hostcomputer carrying out the control generating a plurality of virtualmachines inside the physical machine.

Further, as prior art pertaining to the sharing of I/O devices in avirtual machine, there is known the technology reported inJP-A-2006-855431 (corresponding to U.S. Patent Publication No.2006/0064523) etc.

SUMMARY OF THE INVENTION

However, since the USB device connected with the physical USB port isused for a virtual machine, control showing the connection statereflected in the aforementioned PORTSC register to the USB driver in thevirtual machine became necessary, so processing therefor has becomenecessary.

And then, in order to stably operate a hardware device supplied by ahardware vendor on a virtual machine, the result is that device controlfor virtualization of the USB host controller and physical USB hostcontroller control is installed on an emulating hypervisor, but, even ifan attempt was made to virtualize the physical USB host controller, itis extremely difficult, using the prior art reported in theaforementioned reference JP-A-2006-85543, to guarantee completeoperation of hardware supplied by vendors while ensuring quality andperformance, there being numerous cases in which the detailedspecifications and the like of hardware supplied by vendors are not madepublic.

It is an object of the present invention, taking the aforementionedpoint into consideration, to furnish, in a hypervisor controlling avirtual machine, a USB port shared control method devised to limit, soas to carry out as little as possible, control of a physical deviceconforming to a USB host controller hardware specification which isgenerally made public, and so that a USB host controller device driveroperating in an OS (Operating System) in a virtual machine can occupyand carry out the utilization of a USB port, via a physical USB hostcontroller.

According to the present invention, the aforementioned object is, in aUSB port shared control method letting a plurality of virtual machines,configured inside a physical machine, jointly utilize a physical USBhost controller installed in the physical machine, attained by the factthat: the aforementioned physical machine has a hypervisor constitutinga plurality of virtual machines; and the concerned hypervisor logicallyinstalls the aforementioned physical USB host controller as virtual USBhost controllers in the aforementioned plurality of virtual machines,and, with respect to the USB port controlled by the aforementionedphysical host controller, confers utilization rights to a single virtualmachine and lets it exclusively utilize the aforementioned USB port viathe aforementioned physical USB host controller.

According to the present invention, since the utilization rights areswitched so that a certain single virtual machine can occupy and utilizethe physical USB port, it is possible, for the USB host controllerdevice driver operating in an OS in the virtual machine, to occupy andcarry out the utilization of the USB port via the physical USB hostcontroller.

Other objects, features and advantages of the invention will becomeapparent from the following description of the embodiments of theinvention taken in conjunction with the accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram showing the configuration of a virtual machinesystem switching a USB port, allocating the port utilization rightsexclusively to a single virtual machine, and sharing the USB port.

FIG. 2 is a diagram explaining the control function of a hypervisor forvirtualizing a physical USB host controller and conferring it to avirtual machine.

FIG. 3 is a diagram showing the relation between a physical register ofa physical USB host controller register and a register holding ahypervisor, in the case of letting a single virtual machine exclusivelyuse a USB port via a physical USB host controller.

FIG. 4 is a flowchart describing the functioning of processes in thehypervisor, associated with a USB start operation for allocating theutilization rights of a physical port to a virtual machine and a USBhalt operation for removing the utilization rights from the virtualmachine.

DESCRIPTION OF THE EMBODIMENTS

Hereinafter, a description of an embodiment of a USB port shared controlmethod according to the present invention will be given in detail bymeans of the drawings.

FIG. 1 is a block diagram showing the configuration of a virtual machinesystem switching a USB port, allocating the port utilization rightsexclusively to a single virtual machine, and sharing the USB port.

In a physical machine 10 shown in FIG. 1, a plurality of virtualmachines 100 and 200 are operably constructed and a physical USB hostcontroller 300 and a USB port 21 serving as a control port thereof areprovided. And then, a USB device 20 acting as an I/O device is taken tobe connectable with USB port 21. Although not shown in FIG. 1, thisphysical machine 10 is configured by comprising a CPU (CentralProcessing Unit), a RAM (Random Access Memory), a ROM (Read OnlyMemory), a HDD (Hard Disk Drive), and the like; a hypervisor isconstructed by the CPU's executing a program stored inside the HDD usinga RAM; and by means of the control of this hypervisor, a plurality ofvirtual machines are constructed inside physical machine 10.

Virtual machines 100 and 200 have virtual USB host controllers 102 and202 and virtual USB ports 103 and 203 acting as control ports thereof,and inside virtual machines 100 and 200, there operate OS (OperatingSystems) 101 and 201 comprising USB host controller device drivers 104and 204. And then, virtual USB host controllers 102 and 202 arecontrolled by USB host controller device drivers 104 and 204.

As for the example shown in FIG. 1, it shows a state in which physicalUSB host controller 300 is directly controlled by virtual USB hostcontroller 102, USB host controller device driver 104 of OS 101 invirtual machine 100 occupies USB port 21, and USB device 20 is taken tobe controllable. At this point, OS 201 of virtual machine 200 controlsvirtual USB host controller 202, and, by means of SW (Switch) 400, it isdevised so that access cannot be made to physical USB host controller300, and for this reason, it does not occur that USB host controllerdevice driver 204 is changed while left in the state of virtual USB port203 or in a state not connected with a USB device.

SW 400 is a switching means for letting one of the plurality of virtualmachines occupy physical USB host controller 300 and USB port 21,provided in physical machine 10, that can switch direct control rightsto physical USB host controller 300 (that is, a right for directlycontrolling with respect to physical USB host controller 300),controlled by means of an instruction due to the system administratorfrom control terminal 30 connected with physical machine 10, to eitherof virtual USB host controller 201 or 202 and let virtual machine 100 or200 use USB port 21.

FIG. 2 is a diagram explaining the control function of a hypervisor forvirtualizing a physical USB host controller and conferring it to avirtual machine.

In physical USB host controller 300, there are USB 1.1 host controllerand a USB 2.0 host controller, and in order to implement thesefunctions, there are provided USB 1.1 host controller registers 301 anda USB 2.0 extended host controller register 302. Further, in FIG. 2, USB1.1 host controller registers 301 are shown as existing in severalcopies, but this is for using, in the case where there are providedseveral pairs of a physical USB host controller 300 and a USB port 21provided in physical machine 10 shown in FIG. 1, different ones for thedifferent pairs. Also, in physical USB host controller 300, there may,in the same sense, be provided a plurality of USB 2.0 extended hostcontroller registers 302.

And then, as already explained, inside physical machine 10, there isconfigured a hypervisor 500 constructing a plurality of virtual machines100 and 200. Hypervisor 500 is configured by being provided with a USBhost controller register emulator 510 and a USB host controller portstate administration part 520. In order to make virtual USB hostcontrollers 102 and 202, by which physical USB host controller 300 isvirtualized, visible to virtual machines 100 and 200, USB hostcontroller register emulator 510 of hypervisor 500 emulates the registerstructure of registers 301 and 302 possessed by physical USB hostcontroller 300 and, also, with respect to physical USB host controller300, directly reports read and write requests for register access to andfrom virtual host controller 102 or 202 to control physical USB hostcontroller 300.

By emulation with a register configuration based on the aforementionedUSB host controller register emulator 510, the result is that, insidevirtual USB host controllers 102 and 202 visible from virtual machines100 and 200, there are provided virtual USB 1.1 host controllerregisters 1021 and 2021 and virtual USB 2.0 extended host controllerregisters 1022 and 2022.

USB host controller port state administration part 520 carries outadministration of USB port 21 of physical USB host controller 300, i.e.the control of the physical control rights letting a virtual machine useUSB port 21. In this way, it becomes possible to carry out exclusivecontrol of the utilization of USB port 21 with hypervisor 500.

FIG. 3 is a diagram showing the relation between a physical register ofa physical USB host controller register and a register holding ahypervisor, in the case of letting a single virtual machine exclusivelyuse a USB port via a physical USB host controller, and, with referenceto this diagram, an explanation will be given regarding the mechanism ofimplementing, by means of register emulation, times with utilizationrights, as well as impossibility of utilization, to control a physicalUSB port with respect to a virtual machine.

In FIG. 3, a physical USB register 600 is a register corresponding toUSB 1.1 host controller register 301 or USB 2.0 extended host controllerregister 302, inside physical USB host controller 300 shown in FIG. 2,and is a USB register defined on the basis of a PCI (PeripheralComponent Interconnect) specification or a public specification of a USBhost controller. And then, this physical USB register 600 is configuredby means of a Read attribute register 601, a Read/Write attributeregister 602, and a PORTSC register 603 displaying or controlling theport state thereof.

Hypervisor 500 shows registers 611 to 613 and registers 621 to 623,which are mirrors of each register constituting the aforementionedphysical USB register 600, as USB registers 611-1, 612-1, and 613-1, andUSB registers 621-1, 622-1, and 623-1, to virtual machines 100 and 200,respectively. In the example shown in FIG. 3, hypervisor 500 carries outemulations 640 and 650 validating PORTSC register 613 and confers theutilization rights of the physical USB port to virtual USB register 610.

Further, in FIG. 3, the situation is shown as if virtual USB register610 and virtual USB dummy register 620 were provided inside hypervisor500, but since, as mentioned above, hypervisor 500 is only makingphysical USB register 600 visible to the virtual machines, it does nothold virtual USB register 610 and virtual USB dummy register 620 whichact as entities.

By seeing PORTSC register 613, virtual machine 100 is able to learn thata physical USB port is occupied by its own computer and possible to use.And then, if USB device 20 is mounted in USB port 21, physical USB hostcontroller 300 issues an interrupt command from a not illustratedinterrupt issuing part that is provided in its own controller 300 andmakes hypervisor 500 detect the mounting of the USB device. Theaforementioned interrupt command is transferred, via an interruptcontroller 700 of hypervisor 500, to an interrupt controller 710-1 ofvirtual machine 100 which is a virtual machine in which a physical USBport is occupied and possible to use. In this way, the virtual machinelearns that USB device 20 is mounted in USB port 21 and that access toUSB device 20 has become possible, carries out a Read/Write request tophysical USB register 600, controls the USB port, and can occupy USBdevice 20 mounted in the concerned USB port and start use thereof. Andthen, virtual machine 100 executes transmission and reception of data toand from USB device 20 via a signal line, not shown in FIG. 3, for datatransfers which are set via the hypervisor.

Moreover, there is allocated a virtual USB dummy register 620 ofhypervisor 500 to virtual machine 200 and hypervisor 500 carries out anemulation 651 making PORTSC register 623 invalid, and since it isdevised so as not to receive a report from an interrupt controller720-1, it does not occur that this dummy register exerts an influence onphysical register 600 regarding a request or a report from virtualmachine 200.

FIG. 4 is a flowchart describing the functioning of processes in thehypervisor, associated with a USB start operation for allocating theutilization rights of a physical port to a virtual machine and a USBhalt operation for removing the utilization rights from the virtualmachine; next, an explanation regarding this will be given.

-   1. Now, virtual machine A is in physical register direct access    state A1 and is in a state of being able to utilize a physical USB    port, and virtual machine B is in virtual USB dummy register    allocation state B1, which is taken to be that it is a state in    which exclusive utilization of the USB port is impossible.-   2. In the aforementioned state, if a USB halt operation instruction    O1 from an administrator or the like to virtual machine A via a    control terminal 30 is requested of a hypervisor H, hypervisor H,    since it carries out a virtual USB halt emulation A2, inspects the    physical PORTSC register of the physical USB register, and, in order    to temporarily discontinue the utilization of the USB port in case    the USB port is being utilized, carries out a Suspend setting and a    cancellation in the physical PORTSC register; carries out a USB    device halt write in the PORTSC register of the physical USB    register and processing halting USB host controller communication,    being data transmission and reception which is carried out between    virtual machine 100 and USB device 20 (Process P1); and halts the    access to the physical USB.-   3. Thereafter, hypervisor H sets the USB port to Disable and carries    out a virtual USB register halt emulation (Process P2). Next,    hypervisor H, by reflecting a physical halt state in the PORTSC    register of the virtual USB dummy register and carrying out    processing to make an allocation to a virtual machine (Process P3),    halts the utilization of the USB port from the USB driver control of    virtual machine A. In this state, virtual machine A and virtual    machine B take on a state in which the virtual USB dummy registers    are allocated and the utilization of the USB port becomes impossible    from both of the virtual machines.-   4. Next, if a USB start operation instruction O2 from an    administrator or the like to virtual machine B is requested of    hypervisor H via control terminal 30, hypervisor H, after having    temporarily checked the physical I/O connection state in the PORTSC    register of the physical USB register and carried out physical USB    register initialization processing by means of the same operation    (Process P4), carries out processing mirroring the physical USB    register in the virtual USB register corresponding to virtual    machine B, in order to carry out virtual USB start emulation B2    (Process P5).-   5. Further, in case a USB device is connected with the physical USB    port, hypervisor H carries out port connection emulation processing    for a virtual USB register (Process P6) and, adjusting to the state    in which it is connected with the port, carries out the processing    to allocate the USB register to virtual machine B (Process P7) and    starts physical register direct access B3 and lets virtual machine B    start utilization of the USB port.

According to the aforementioned embodiment of the present invention,since it is possible for the hypervisor to carry out exclusive controlso as to carry out allocation, with respect to a certain single virtualmachine having direct access utilization rights, of physical USBregisters, it becomes possible for the single virtual machine to occupyand utilize the USB port.

Also, according to the embodiment of the present invention, from thephysical host controller, it looks like the virtual USB host controlleris mounted to a plurality of respective virtual machines, so it becomespossible to switch the utilization rights of, and utilize, the physicalUSB port with a certain single virtual machine, and since it is possibleto utilize the USB port by occupying it, not necessitating a recognitionagain of the USB host controller, the OS of the virtual machine can omitemulation processing concerned with I/O drive control based on ahypervisor and reduce overhead based thereon.

In addition, according to the embodiment of the present invention, sinceit is possible to carry out the development of installing fakeoverwrites of the physical host controller for the unmounting andmounting of a USB device in a USB port, and virtual USB host controlleremulations, without emulating any host controller specifications, onecan reduce the man-hours, expenses, and time related to development,making it possible to strive for cost reductions.

As for the processing in the hypervisor, associated with theaforementioned embodiment of the present invention, it is possible tohave it executed by a CPU configured by a program and provided by aphysical machine, and also, it is possible to supply the same programson a recording medium such as a FD (Floppy Disk), a CDROM (Compact DiscRead Only Memory), or a DVD (Digital Versatile Disc); in addition, it ispossible to supply the same by means of digital information via anetwork.

As for the embodiment of the present invention described in theforegoing, in case of taking into account the USB utilization state on avirtual machine in a server system, there is generally assumed the caseof its being utilized for the uses of OS installation and driverinstallation or user data input and output, but in the case where thereis normally no necessity of mounting a USB device in a USB port andoperating it, it is a valid utilization method to utilize the USB deviceby switching the utilization of the USB port based on operations fromthe administrator, since it is assumed that the USB device is treated asa temporary external medium.

Moreover, as for the aforementioned embodiment of the present invention,since, on the occasion of a modification in the utilization betweenvirtual machines of a USB device connected with a physical machine, anOS restart or a renewed search of the USB host controller is not takento be necessary, so it is possible to utilize the device driver in astable manner.

It should be further understood by those skilled in the art thatalthough the foregoing description has been made on embodiments of theinvention, the invention is not limited thereto and various changes andmodifications may be made without departing from the spirit of theinvention and the scope of the appended claims.

1. A Universal Serial Bus (USB) port shared control method which isexecuted by a hypervisor in order for the hypervisor to control sharingof the USB port among a plurality of virtual machines, in a computerwhich comprises a physical USB host controller being configured toinclude a physical register and to control the USB port and thehypervisor that constitutes the plurality of virtual machines eachincluding a virtual USB host controller having a virtual register, themethod comprising: selectively allocating the physical register to thevirtual register of a first virtual USB host controller provided in afirst virtual machine of the plurality of virtual machines to occupy andunitize the USB port by the first virtual machine, and directly readingor writing of the physical register by the first virtual machine via thefirst virtual USB host controller, to thereby allow the first virtualUSB host controller to directly control the physical USB hostcontroller; emulating halt of the USB port with respect to the firstvirtual machine in response to an instruction from an outside andallocating a dummy register reflecting a halt state to the virtualregister of the first virtual USB host controller to thereby haltutilization of the USB port by the first virtual machine; andselectively allocating the physical register to the virtual register ofa second virtual USB host controller provided in a second virtualmachine of the plurality of virtual machines to occupy and unitize theUSB port by the second virtual machine, and directly reading or writingof the physical register by the second virtual machine via the secondvirtual USB host controller, to thereby allow the second virtual USBhost controller to directly control the physical USB host controller. 2.The USB port shared control method according to claim 1, wherein theoccupying and unitizing the USB port by the second virtual machine,includes a substep of emulating connection of the USB port with respectto the second virtual machine when a USB device is connected with theUSB port.
 3. The USB port shared control method according to claim 2,further comprising: when an interrupt command is issued from thephysical USB host controller, selectively transmitting the interruptcommand to the second virtual machine occupying and unitizing the USBport.